//
// Copyright (c) 2024 BPer
//

#ifndef BPERENCODER_INCLUDE_BPERAUDIOENCODERHANDLECB_H_
#define BPERENCODER_INCLUDE_BPERAUDIOENCODERHANDLECB_H_

#include <bperutil/sys/BPerThread2.h>
#include <bperutil/buffer/BPerAudioEncoderBuffer.h>
#include <bperutil/buffer/BPerAudioPlayBuffer.h>
#include <bperencoder/BPerAudioEncoder.h>
#include <vector>

using namespace std;
class BPerAudioEncoderHandleCb:public BPerThread
{
public:
	BPerAudioEncoderHandleCb(BPerAudioInfo *pcontext);
	~BPerAudioEncoderHandleCb(void);

private:
	int32_t m_isInit;

public:
	void init();
	void stop();
	void setInAudioBuffer(BPerAudioBuffer *pbuf);

	void setCallback(BPerEncoderCallback* pcb);

	int32_t m_isStart;
	int32_t m_uid;



protected:
	void run();
	void stopLoop();
	void startLoop();

void saveFile(char *fileName, uint8_t *pBuffer, long BufferLen);

private:
	BPerEncoderCallback* m_cb;
	BPerAudioEncoder *m_enc;
	int32_t m_isConvert;

	BPerAudioBuffer *m_in_audioBuffer;

	BPerAudioInfo *m_context;
	void Encoder(int32_t isIframe,uint8_t*src,int32_t  p_buflen,uint8_t *dest,int32_t *p_destLen);

};
#endif /* BPERENCODER_INCLUDE_BPERAUDIOENCODERHANDLECB_H_ */
